<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>意见收集</title>
    <link rel="stylesheet" href="${ctxPath}/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctxPath}/assets/module/admin.css"/>
    <link rel="stylesheet" href="${ctxPath}/assets/libs/zTree/css/zTreeStyle/zTreeStyle.css"/>
</head>

<body>
<% include("../layout/loading.html"){} %>

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">

            <table class="layui-table" id="orderTable" lay-filter="orderTable"></table>
        </div>
    </div>
</div>


<!-- 表格操作列 -->
<script type="text/html" id="tableBar">
    {{# if(d.status==1){ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs " id="update-class-{{d.id}}" style="display:none;" lay-event="updateStatus">处理</a>
    {{# }else{ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs " id="update-class-{{d.id}}" lay-event="updateStatus">处理</a>
    {{# } }}
</script>
<!-- 表单弹窗 -->
<script type="text/html" id="modelContact">
    <form id="modelContactForm" lay-filter="modelContactForm" class="layui-form model-form">
        <input name="id" type="hidden"/>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注:</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入" class="layui-textarea" name="remark"></textarea>
            </div>
        </div>
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">备注:</label>-->
<!--            <div class="layui-input-block">-->
<!--                <input name="remark" placeholder="请输入" type="text" class="layui-input" maxlength="20"-->
<!--                       lay-verType="tips" lay-verify="required" required/>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="contactSubmit" lay-submit>确定</button>
        </div>
    </form>
</script>
<!-- js部分 -->
<script type="text/javascript" src="${ctxPath}/assets/libs/jquery/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/libs/zTree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/js/common.js"></script>
<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin','laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        var util = layui.util;
        var admin = layui.admin;
        laydate.render({elem: '#searchDate', range: true,value: '',isInitValue:true});

        // 渲染表格
        var insTb = table.render({
            elem: '#orderTable',
            url: '/admin/contact/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers'},
                {field: 'childName', title: '学员姓名'},
                {field: 'telNo', title: '手机号'},
                {field: 'content', title: '意见反馈'},
                {field: 'createdDate', title: '提交时间'},
                {field: 'remark', title: '备注'},
                {align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 200}
            ]]
        });

        // 工具条点击事件
        table.on('tool(orderTable)', function (obj) {
            var data = obj.data;
            console.log(data);
            var layEvent = obj.event;
            if (layEvent === 'updateStatus') { // 完成取货
                updateStatus(obj);
            }
        });
        // 处理意见反馈
        function updateStatus(obj) {
            admin.open({
                type: 1,
                title:  '备注',
                content: $('#modelContact').html(),
                success: function (layero, dIndex) {
                    var url = '/admin/contact/updateStatus';
                    // 表单提交事件
                    form.on('submit(contactSubmit)', function (data) {
                        layer.load(2);
                        $.post(url, {remark:data.field.remark,id:obj.data.id}, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                insTb.reload();
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'json');
                        return false;
                    });
                }
            });
        }
    });
</script>
</body>
</html>